package lapsnake.model.stmt;

import lapsnake.model.*;
import lapsnake.model.data.*;
import lapsnake.model.data.OptionalChild;
import lapsnake.model.data.SingleChild;
import lapsnake.py.ast.ASTHelperFactory; import java.beans.PropertyVetoException;

import org.python.antlr.ast.*;

/**Wrapper class with helper functions for Exec nodes
 * 
 * Note: if globals is defined, then locals is not optional.
 * In other words, locals can only be defined if globals is.*/
public class LapExec extends LapStatement {
	public final SingleChild<LapExpression> body = new SingleChild<>(this, LapExpression.class);
	public final OptionalChild<LapExpression> globals = new OptionalChild<>(this, LapExpression.class);
	public final OptionalChild<LapExpression> locals = new OptionalChild<>(this, LapExpression.class);
	
	public LapExec(PyAST pyAST, ChildField<? super LapExec> parent, Exec node) throws PropertyVetoException {
		super(pyAST, parent, node);
		
		ASTHelperFactory.makeHelper(pyAST, body, node.getInternalBody());
		ASTHelperFactory.makeHelper(pyAST, globals, node.getInternalGlobals());
		ASTHelperFactory.makeHelper(pyAST, locals, node.getInternalLocals());
		
		buildTextNodes(node);
	}
}
